package com.nartosoft.tubuloader;

import java.util.ArrayList;
import java.util.List;

public class EventDispatcher {
	private final List<EventListener> eventListeners; // contains EventListener objects

	public EventDispatcher() {
		eventListeners = new ArrayList<EventListener>();
	}

	public void addEventListener(EventListener listener) {
		if (listener != null && !eventListeners.contains(listener)) {
			eventListeners.add(listener);
		}
	}

	public void notifyUpload(String imageFileName, String url) {
		for (EventListener el:eventListeners) {
			el.onUpload(imageFileName, url);
		}
	}

	public void notifyError(String message) {
		for (EventListener el:eventListeners) {
			el.onError(message);
		}
	}

	public void notifyAllDone() {
		for (EventListener el:eventListeners) {
			el.onAllFilesDone();
		}
	}
}
